package com.dkm.ec.so.domain;

import java.util.concurrent.ConcurrentHashMap;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.base.core.util.string.StringUtils;
import com.dkm.biz.domain.AbstractDomain;
import com.dkm.ec.so.persistence.dao.SaleReviewImgDao;
import com.dkm.ec.so.persistence.entity.SaleReviewImgPo;
import com.dkm.ec.so.repository.SaleReviewImgRepository;

/**
 * 对象功能:评价图片 领域对象实体
 * 开发公司:SKG.COM
 * 开发人员:颜超敏
 * 创建时间:2015-02-10 11:09:39
 */
@SuppressWarnings("serial")
@Service
@Scope("prototype")
public class SaleReviewImg extends AbstractDomain<String, SaleReviewImgPo>{
	 
	 private SaleReviewImgDao saleReviewImgDao = null;
	 @Resource
	 private  SaleReviewImgRepository saleReviewImgRepository;

	protected void init(){
		saleReviewImgDao = SpringHelper.getBean(SaleReviewImgDao.class);
		setDao(saleReviewImgDao);
	}	 
	 
	/**
	 * 添加晒单
	 * 
	 * @param id
	 *            评价ID
	 */
	public void addSaleReviewImg(String id, String imgUrls) {
		if (StringUtils.isEmpty(id) || StringUtils.isEmpty(imgUrls)) {
			return;
		}
		String[] imgUrlArray = imgUrls.split(",");
		SaleReviewImg saleReviewImg;
		ConcurrentHashMap<String, String>map = new ConcurrentHashMap<String, String>(); 
		for (String imgUrl : imgUrlArray) {
			saleReviewImg = saleReviewImgRepository.newInstance();
			SaleReviewImgPo po = new SaleReviewImgPo();
			po.setReviewId(id);
			po.setImgUrl(imgUrl);
			saleReviewImg.setData(po);
			saleReviewImg.save();
			map.put(po.getImgUrl(), po.getId());
		}
	}
}
